const ADD_ITEMNUM = 'ADD_ITEMNUM'
const REMBER_ANSWER = 'REMBER_ANSWER'
const REMBER_TIME = 'REMBER_TIME'
const INITIALIZE_DATA = 'INITIALIZE_DATA'
const PULL_DATA = 'PULL_DATA'

export default {

  // 点击进入下一题
  [ADD_ITEMNUM](state, num) {
    state.itemNum += num;
  },

  // 将用户选择的答案放入state.answerid数组中，记录下来
  [REMBER_ANSWER](state, id) {
    state.answerid.push(id);
  },

  // 开始计时，每隔一秒，总时间加一秒
  [REMBER_TIME](state) {
    state.timer = setInterval(() => {
      state.allTimer++;
    }, 1000)
  },

  // 初始化数据
  [INITIALIZE_DATA](state) {
    state.itemNum = 1;
    state.allTimer = 0;
    state.answerid = [];
  },

  // 拉取数据
  [PULL_DATA](state, data) {
    state.level = data.level;
    state.itemDetail = data.itemDetail;
  },
}